package com.example.rzprogram;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.base.BaseActivity;
import com.example.bean.ZixunDelBean;
import com.example.bean.Zixundel;
import com.example.network.ProtocolService;
import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;

public class ZixunDelActivity extends BaseActivity {

	@ViewInject(R.id.btn_yimin)
	private TextView tv_yimin;
	@ViewInject(R.id.btn_menu)
	private Button menu;
	@ViewInject (R.id.title)
	private TextView tv_title;
	@ViewInject(R.id.btn_percenter)
	private Button pecennter;
	@ViewInject(R.id.head_img)
	private ImageView img;
	@ViewInject(R.id.content)
	private TextView tv_content;
	@ViewInject(R.id.gongsiname)
	private TextView tv_name;
	@ViewInject(R.id.gongsiplace)
	private TextView tv_place;
	@ViewInject(R.id.gongsitell)
	private TextView tv_tell;
	
	private Zixundel data;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_yimindel);
		ViewUtils.inject(this);
		ProtocolService.zixunDetil("autoID", new RequestCallBack<String>() {
			
			@Override
			public void onSuccess(ResponseInfo<String> arg0) {
				// 解析数据
					ZixunDelBean bean = com.alibaba.fastjson.JSONObject.parseObject(
							arg0.toString(), ZixunDelBean.class);
					data = bean.getNewsinfo();
					
					BitmapUtils bitmapUtils = new BitmapUtils(ZixunDelActivity.this);
					bitmapUtils.display(img, data.getImagePath());
					tv_title.setText(data.getNewsTitle());
					tv_content.setText(data.getNewsContent());
					tv_name.setText(data.getSendUser());
					tv_place.setText(data.getUserProvince());
//					tv_tell.setText(data.get)
			}
			
			@Override
			public void onFailure(HttpException arg0, String arg1) {
				// TODO Auto-generated method stub
				
			}
		});
	}
		@OnClick({ R.id.btn_menu, R.id.btn_percenter})
	public void onCliecks(View v) {
		switch (v.getId()) {
		case R.id.btn_menu:
			//菜单
			break;
		case R.id.btn_percenter:
			 Intent intent = new Intent(ZixunDelActivity.this,
					 MainActivity.class);
			 startActivity(intent);
			break;
		}
	}

}
